package cn.wolfcode.crm.service.imp;

import cn.wolfcode.crm.domain.Train;
import cn.wolfcode.crm.mapper.TrainMapper;
import cn.wolfcode.crm.qo.PageResult;
import cn.wolfcode.crm.qo.QueryObject;
import cn.wolfcode.crm.service.ITrainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class TrainServiceImpl implements ITrainService {
    @Autowired
    private TrainMapper trainMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return trainMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Train record) {
        return trainMapper.insert(record);
    }

    @Override
    public PageResult query(QueryObject qo) {
        int rows = trainMapper.rows(qo);
        if (rows == 0) {
            return  PageResult.EMPTY_RESULT;
        }
        PageResult result =   new PageResult(rows,trainMapper.queryForList(qo));
        return result;

    }

    @Override
    public List<Train> selectAll() {
        return trainMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(Train record) {
        return trainMapper.updateByPrimaryKey(record);
    }
}
